package day07;
import sun.security.jgss.GSSCaller;
import java.util.Scanner;
public class Day07HomeWork01 {
    public static void main(String[] args) {
    //==============================机票打折==========================================
        /*Scanner scan=new Scanner(System.in);
        System.out.println("钱");
        double money=scan.nextDouble();
        System.out.println("月");
        int month=scan.nextInt();
        System.out.println("舱，1,2,3");
        int type=scan.nextInt();
        System.out.println("最后为："+price(money,month,type));*/
    //=================================成绩========================================
        /*double[] score=score();
        System.out.println(score);
        double num=score(score);
        System.out.println(num);
        double scoreavg=scoreAvg(score);
        System.out.println(scoreavg);*/
    //==================================猜大小========================================
       /* Scanner scan=new Scanner(System.in);
        System.out.println("开始");
        int answer=(int)(Math.random()*100);
        while (true){
            int guess=scan.nextInt();
            if(guess<answer){
                System.out.println("小了");
            }else if(guess>answer){
                System.out.println("大了");
            }else {
                System.out.println("对了");
                break;
            }
        }*/
    //=====================================求素数========================================
       /* for (int num=2;num<=100;num++){
            boolean flag=true;
            for (int i=2;i<num/2;i++){
                if(num%2==0){
                    flag=false;
                    break;
                }
            }
            if(flag){
                System.out.println(num);
            }
        }*/
    //=====================================验证码==========================================
       String code=generateVeriCode(10);
        System.out.println(code);

    }



    //计算打折
    public static double price(double money,int month,int type){
        if(month>4||month<11){
            switch (type){
                case 1:
                    money*=0.7;
                    break;
                case 2:
                    money*=0.75;
                    break;
                case 3:
                    money*=0.8;
                default:
                    System.out.println("输入错误");

            }
        }else{
            switch (type){
                case 1:
                    money*=0.6;
                    break;
                case 2:
                    money*=0.65;
                    break;
                case 3:
                    money*=0.7;
                default:
                    System.out.println("输入错误");

            }
        }
        return money;
    }

    //录入成绩
    public static double[] score(){
        double[] score=new double[6];
        Scanner scan=new Scanner(System.in);
        for (int i=0;i<score.length;i++){
            System.out.println("请输入"+(i+1)+"号评委分数");
            score[i]=scan.nextDouble();
        }
        return score;
    }
    //总分
    public static double score(double[]score){
        double max=score[0];
        double min=score[0];
        double score1=0;
        for(int i=0;i<score.length;i++){
            if(max<score[i]){
                max=score[i];
            }
            if(min>score[i]){
                min=score[i];
            }
            score1+=score[i];
        }
    return score1-min-max;
    }
    //平均分
    public static double scoreAvg(double[]score2){
        double scoreavg=score(score2)/(score2.length-2);
        return scoreavg;
    }
   //验证码
    public static String generateVeriCode(int len){
        String gen="";
        char[] code={'a','b','c','d','e','f','g','h','i','j','k',
                'l','m','n','o','p','q','r','s','t','u','v',
                'w','x','y','z','A','B','C','D','E','F','G','H'
                ,'I','J','K','L','M','N','O','P','Q','R','S','T',
                'U','V','W','X','Y','Z','1','2','3','4','5','6',
                '7','8','9','0'};
        for(int i=1;i<len;i++){
            int id=(int) (Math.random()*code.length);
            gen+=code[id];
        }
        return gen;
    }
}
